package com.wd.buycar.view.adapter

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ToastUtils
import com.bumptech.glide.Glide
import com.wd.buycar.R
import com.wd.buycar.view.activity.NewCarDetailsActivity
import com.wd.common.bean.ContrastBean
import com.wd.common.bean.QuickSearchBean


class ContrastAdapter(
    private var context: Context,
    private var list: ArrayList<ContrastBean.Result>,
) : RecyclerView.Adapter<ContrastAdapter.Holder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val view = LayoutInflater.from(context).inflate(R.layout.contrast_item, parent, false)
        return Holder(view)
    }

    override fun getItemCount() = list.size

    override fun onBindViewHolder(holder: Holder, position: Int) {
        val result = list[position]
        val carInfo = result.carInfoList[0]
        val detailList = carInfo.detailList

        holder.pin.text = detailList?.get(0)!!.propertyValue
        holder.price.text = detailList?.get(1)!!.propertyValue+"W"
        holder.jb.text = detailList?.get(2)!!.propertyValue
        holder.ss.text = detailList?.get(3)!!.propertyValue
        holder.gb.text = detailList?.get(4)!!.propertyValue

        val carInfo2 = result.carInfoList[1]
        val detailList2 = carInfo2.detailList
        holder.csjg.text = detailList2?.get(0)!!.propertyValue
        holder.zws.text = detailList2?.get(1)!!.propertyValue
    }

    class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val pin : TextView
        val price : TextView
        val jb : TextView
        val ss : TextView
        val gb : TextView
        val csjg : TextView
        val zws : TextView

        init {
            pin = itemView.findViewById(R.id.pin)
            price = itemView.findViewById(R.id.constrast_price)
            jb = itemView.findViewById(R.id.constrast_jb)
            ss = itemView.findViewById(R.id.constrast_ss)
            gb = itemView.findViewById(R.id.constrast_gb)
            csjg = itemView.findViewById(R.id.constrast_csjg)
            zws = itemView.findViewById(R.id.constrast_zws)
        }
    }
}